// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env: 'cloud-dev-alpha-3f1k3'
})

const db = cloud.database()
const _ = db.command

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  console.log(event)
  return await db.collection('card').doc(event._id).update({
    data: {
      cnt: _.inc(-1),
      phone: _.pop(event.phone)
    },
    success: res=>{
      console.log("修改卡片记录成功！")
    },
    fail: res=>{
      console.log("修改卡片记录失败！！！")
    }
  })
}